﻿if (typeof Axis == "undefined") Axis = {};
if (typeof Axis.View == "undefined") Axis.View = {};
if (typeof Axis.View.Member == "undefined") Axis.View.Member = {};
Axis.View.Member.MemberGift = {
    Init: function () {
        var thisObj = this;
        thisObj.GetMemberGift();
    },
    GetMemberGift: function () {
        $.Ajax({
            url: "/Views/Gift/Service/GiftService.asmx/GetMemberGift",
            type: 'POST',
            data: {},
            beforeSend: function () {
            },
            success: function (data, textStatus, xhr) {
                var ret = "";
                if (data) {
                    data = $.findInXml(data);
                    data = eval("(" + data + ")");
                    var ret = '';
                    if (data) {
                        $.each(data, function (index, item) {
                            if (data.length > 2) {
                                if (index > data.length - 3) {
                                    ret += ''
                                + $.string.Format('<li class="giftOfmember_item" gift-id="{0}">', item.ID)
                                    + '<div class="giftOfmember_item_box">'
                                        + $.string.Format('<img class="giftOfmember_item_image" src="{0}" />', item.Image)
                                        + $.string.Format('<span class="giftOfmember_item_name">{0}</span>', item.Name)
                                    + '</div>'
                                + '</li>';
                                }
                            }
                            else {
                                ret += ''
                                + $.string.Format('<li class="giftOfmember_item" gift-id="{0}">', item.ID)
                                    + '<div class="giftOfmember_item_box">'
                                        + $.string.Format('<img class="giftOfmember_item_image" src="{0}" />', item.Image)
                                        + $.string.Format('<span class="giftOfmember_item_name">{0}</span>', item.Name)
                                    + '</div>'
                                + '</li>';
                            }
                        });
                    }
                }
                $(".giftOfmember_list").html(ret);
            },
            error: function (xhr, textStatus, errorThrown) { }
        });
    }
};
$(function () {
    Axis.View.Member.MemberGift.Init();
});